import scapy.all as scapy
import os
import scapy_http.http


def XSS():  # XSS
    path = "pcap_log"
    files = os.listdir(path)
    for file in files:  # 遍历文件夹
        packets = scapy.rdpcap(path + '\\' + file)

        for p in packets:
            # print(p[1].mysummary)
            hello = str(p[1].mysummary)
            if "alert" in hello:
                dst = str(p[1].dst)
                dport = str(p[1].dport)
                src = str(p[1].src)
                sport = str(p[1].sport)
                proto = str(p[1].proto)
                print("存在XSS")
                print(hello)


def SQL():  # XSS
    path = "Pcap_log"
    files = os.listdir(path)
    for file in files:  # 遍历文件夹
        packets = scapy.rdpcap(path + '\\' + file)

        for p in packets:

            hello = str(p[1].mysummary)
            if "alert" in hello:
                dst = str(p[1].dst)
                dport = str(p[1].dport)
                src = str(p[1].src)
                sport = str(p[1].sport)
                proto = str(p[1].proto)

                print("存在XSS")
                print(hello)


XSS()